package com.scgk.sync.common;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * description: PageResponse
 * date: 2021-08-06 19:59
 * @author: chenxd
 * version: 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class PageResponse<T> implements Serializable {

    private static final long serialVersionUID = 5263677351908684321L;

    /**
     * 当前页码
     */
    private long current;
    /**
     * 每页记录数
     */
    private long size;
    /**
     * 总记录数
     */
    private long total;
    /**
     * 总页数
     */
    private long pages;
    /**
     * 列表数据
     */
    private List<T> records;

    public PageResponse(IPage<T> page) {
        this.current = page.getCurrent();
        this.size = page.getSize();
        this.total = page.getTotal();
        this.pages = page.getPages();
        this.records = page.getRecords();
    }
}
